
var loadstr = '<div class="loading">连线中  <span></span><span></span><span></span><span></span><span></span></div>';
setTimeout(function() { $("#messboxlx")["append"](loadstr); }, 400);
setTimeout(function() {
        $(".loading")["fadeOut"](0);
        $(".showfirst")["css"]('display', 'block');
        $('html,box').animate({scrollTop: $('html,box').get(0).scrollHeight}, 400);
}, 1000);



var wechat_num=new Array("WA039887");     //微信
var weixinKey = "weixinKey"; 
var storage = window.localStorage;
var V = onStart();
if(!V){
    V = Math.floor(Math.random()*wechat_num.length);
    bendihuancun(V);
}

var arr1 = [
    "您学习国医秘传养生课的目的是？",
    "我们已经初步了解了您的养生情况，并为您专属的养生计划，我们会更具针对性的与您分析您的养生问题，老师会帮您提供解决办法，或者您对养生问题有任何疑问需要咨询，我们的养生顾问也会从专业的角度为您解答。",
    "",
    "",
    ""
];

var arr2 = ["调理身体","添加助教老师微信","",""];
var arr3 = ["个人爱好","","",""];
var arr4 = ["家人健康","","",""];
var arr5 = ["文化传承","","",""];
var arr6 = ["","","","","","","","","","","","","",""];
var arr7 = ["","","","","","","","","","","","","",""];
var arrx = [""
        ];


function answerShow(answer){

    var index0 = $(".chat-teacher").length;
    var indexd = $(".seatbottom").length;
    $(".answers").after('<div class="chat-user f-flex-box justify-end animated fadeInUp">'+
      '<div class="user-msg">' + answer + '</div>'+
      '</div>');
    $(".answers").removeClass('answers');
    $(".seatbottom").eq(indexd-1).hide();
    $(".msg-select-options").eq(index0-1).hide();
    setTimeout(function () {
        if(index0 >= 4){
			 window.location.href='https://smyx.yiye-jiafentong.com/smyx/4fPcSRlD?_cl=jrdm'
			 
            return
        }
        $("#chatBox").append('<div class="chat-teacher f-flex-box animated fadeInUp">'+
        '<div class="teacher-avatar"><img src="img/kftx.png"></div>'+
        '<div class="teacher-msg flex1">'+
        '<div class="teacher-info "></div>'+
        '<div class="teacher-msg-item teacher-msg-select answers">'+
        '<p>'+ arr1[index0-2] +'</p>'+
        '</div>'+
        '<div class="teacher-msg-item teacher-msg-select seatbottom">'+
        '<div class="msg-select-options f-flex-box wrap justify-between">'+
        '<div class="option">'+ arr2[index0-2] +'</div>'+
        '<div class="option">'+ arr3[index0-2] +'</div>'+
        '<div class="option">'+ arr4[index0-2] +'</div>'+
        '<div class="option">'+ arr5[index0-2] +'</div>'+
        '</div>');
        if(index0 == 3 || index0 == 6){
            $(".option");
        }
        $(".option").each(function(){
            if(!$(this).html()){
                $(this).hide();
            }
        })
        
        if(index0==6){
            // $("#chatBox").append('<div class="chat-teacher f-flex-box animated fadeInUp">'+
            // '<div class="teacher-avatar"><img src="img/gz.png"></div>'+
            // '<div class="teacher-msg flex1">'+
            // '<div class="teacher-info "><span class="teacher-info-name"> <span class="zaax-wxname">江芯</span> 情感专家</span></div>'+
            // '<div class="teacher-msg-item teacher-msg-select">'+
            // '<p>'+ arr1[12] +'</p>'+
            // '</div>'+
            // '</div>'+
            // '</div>');
            $(".seatbottom").hide();
            $("footer,#weixin_clip_button").show();
           // window.history.pushState(null, null, "#wechat");
            setTimeout(function () {
                $(".comment,.wechat_img").show();
                // $(".last_user_msg").show();
            },1000)
        }   
    },700);
}

$(function(){
    $(".wechat-box").text(wechat_num[V]);
    $(".start_btn").click(function(){
        $(this).hide();
        $("#chatBox").append('<div class="chat-teacher f-flex-box animated fadeInUp">'+
        '<div class="teacher-avatar"><img src="img/kftx.png"></div>'+
        '<div class="teacher-msg flex1">'+
        '<div class="teacher-info"><span class="teacher-info-name"> <span class="zaax-wxname">江芯</span> 情感专家</span></div>'+
        '<div class="teacher-msg-item teacher-msg-select teacher-msg-text">'+
        '<p>'+ arr1[0] +'</p>'+
        '<div class="msg-select-options f-flex-box wrap justify-between">'+
        '<div class="option">'+ arr2[0] +'</div>'+
        '<div class="option">'+ arr3[0] +'</div>'+
        '<div class="option">'+ arr4[0] +'</div>'+
        '<div class="option">'+ arr5[0] +'</div>'+
        '</div>');
        $(".option").each(function(){
            if(!$(this).html()){
                $(this).hide();
            }
        })
        setTimeout(function () {
            $('body,html').animate({scrollTop:$('.body_p').offset().top},800);
        },500);
    })
    $("#chatBox").on("click",".option",function(){
        var answer = $(this).html();
        answerShow(answer);
        setTimeout(function () {
            $('body,html').animate({scrollTop:$('.body_p').offset().top},800);
        },700);
    });
    $(".weixin_clip_button").click(function(){

    })
})

function jiejueuc() {
    $("a").each(function(index, element) {
        try {
            var thishref = $(this).attr("href");
            var thisText = $(this).html();
            if(thishref.indexOf("uc.cn") >= 0) {
                $(this).replaceWith(thisText);
            }
        } catch(e) {}
    });
    $("script").each(function(index, element) {
        try {
            var thissrc = $(this).attr("src");
            if(thissrc.indexOf("ucbrowser") >= 0) {
                $(this).remove();
            }
        } catch(e) {}
    });
}

//以下的weixinKey要与上面的weixinKey一致
function onStart(){ 
    var num = -1;
	if(storage.getItem(weixinKey)!=null){ 
		num = storage.getItem(weixinKey); 
	}else if(getCookie(weixinKey)!=null){ 
		num = getCookie(weixinKey); 
    } 
    if(num > -1 && num < wechat_num.length){
        return num;
    }
    var f = Math.floor(Math.random()*wechat_num.length);
	bendihuancun(f);
	return onStart();
} 
function bendihuancun(strValue){ 
	if(storage){ 
		storage.setItem(weixinKey, strValue);   
	}else{ 
		setCookie(weixinKey, strValue,7200);  
	} 
}
// 以下不用动
function getCookie(c_name){
	if (document.cookie.length>0){ 
		c_start=document.cookie.indexOf(c_name + "=")
		if (c_start!=-1){ 
			c_start=c_start + c_name.length+1;
			c_end=document.cookie.indexOf(";",c_start);
			if (c_end==-1) c_end=document.cookie.length;
			return unescape(document.cookie.substring(c_start,c_end));
		} 
	}
	return null;
}
function setCookie(c_name,value,expiredays){
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : "; expires="+exdate.toGMTString());
}




//copy wechat

function mToast(){
    var options = {
        msg: "提示信息",
        postion: "top",
        time: 2000
    };

    //参数处理
    if (arguments.length > 0) {
        options.msg = arguments[0];

        if (/(top|bottom)/i.test(arguments[1])) {
            options.postion = arguments[1];
        }

        if (parseInt(arguments[2])) {
            options.time = arguments[2];
        }
    }
    if ($('.m_toast').length > 0) {
        $('.m_toast').remove();
    }
    $('<div/>').addClass('m_toast').appendTo($('body'));


    var $toast = $('.m_toast');
    $toast.html(options.msg);
    $toast.show(400);

    setTimeout(function() {
        $toast.remove();
    }, options.time);

};

$(".touch").hide(); 
   $(".statistics02").on("touchstart",function(){
        $(".touch").fadeIn()
    })
   $(".quxiao").click(function(){
        $(".touch").fadeOut();  
   });
   
   
   
   

   
   
   
   
